/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ventasautomotrices;

import javax.swing.JTextArea;

/**
 *
 * @author Alejandra
 */
public class ConsultaAutos extends javax.swing.JFrame {

    /**
     * Creates new form ConsultaAutos
     */
    
    ControlDatos controld= new ControlDatos();
    public ConsultaAutos() {
        initComponents();
    }

    public void setMarca(int ind){
        this.marcaCB.setSelectedIndex(ind);
    }
    
    public JTextArea getTxtResultados(){
        return txtResultados;
    }
    
    public void setChkBuscar(int ind, boolean activate){
        if(ind==1){
            this.chkBuscarMarca.setSelected(activate);
        }else if(ind==2){
            this.chkBuscarModelo.setSelected(activate);
        }else if(ind==3){
            this.chkBuscarLinea.setSelected(activate);
        }else if(ind==4){
            this.chkBuscarTipo.setSelected(activate);
        }else if(ind==5){
            this.chkBuscarColor.setSelected(activate);
        }else if(ind==6){
            this.chkBuscarEstado.setSelected(activate);
        }else if(ind==7){
            this.chkBuscarPlaca.setSelected(activate);
        }
    }
    
    public void buscar(){
        String mar = "";
        if(this.chkBuscarMarca.isSelected())
            mar = this.marcaCB.getSelectedItem().toString();
        String mod = "";
        if(this.chkBuscarModelo.isSelected())
            mod = this.modeloTF.getText();
        String lin = "";
        if(this.chkBuscarLinea.isSelected())
            lin = this.lineaTB.getText();
        String tip = "";
        if(this.chkBuscarTipo.isSelected())
            tip = this.tipoCB.getSelectedItem().toString();
        String color = "";
        if(this.chkBuscarColor.isSelected())
            color = this.colorCB.getSelectedItem().toString();
        String est = "";
        if(this.chkBuscarEstado.isSelected())
            est = this.estadoCB.getSelectedItem().toString();
        String pla = "";
        if(this.chkBuscarPlaca.isSelected())
            pla = this.placaTB.getText();
        
        this.txtResultados.setText("");
        this.txtResultados.setText(controld.ConsultarAuto(mar,mod,lin,tip,color,est,pla));
        
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnConsultar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        marcaCB = new javax.swing.JComboBox();
        modeloTF = new javax.swing.JTextField();
        lineaTB = new javax.swing.JTextField();
        tipoCB = new javax.swing.JComboBox();
        colorCB = new javax.swing.JComboBox();
        estadoCB = new javax.swing.JComboBox();
        placaTB = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtResultados = new javax.swing.JTextArea();
        chkBuscarMarca = new javax.swing.JCheckBox();
        chkBuscarModelo = new javax.swing.JCheckBox();
        chkBuscarLinea = new javax.swing.JCheckBox();
        chkBuscarTipo = new javax.swing.JCheckBox();
        chkBuscarColor = new javax.swing.JCheckBox();
        chkBuscarEstado = new javax.swing.JCheckBox();
        chkBuscarPlaca = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        btnConsultar.setText("Consultar");
        btnConsultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultarActionPerformed(evt);
            }
        });

        jLabel1.setText("Marca:");

        jLabel2.setText("Modelo:");

        jLabel3.setText("Línea:");

        jLabel4.setText("Tipo:");

        jLabel5.setText("Color:");

        jLabel6.setText("Estado:");

        jLabel7.setText("Placa:");

        marcaCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Audi", "BMW", "Chevrolet", "Dodge Ram", "Ford", "Kia", "Mazda", "Mercedez-Benz", "Mitsubishi", "Nissan", "Suzuki", "Honda", "Toyota", "Volvo" }));
        marcaCB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                marcaCBActionPerformed(evt);
            }
        });

        modeloTF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                modeloTFActionPerformed(evt);
            }
        });

        tipoCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Camioneta", "Sedan", "Coupé" }));

        colorCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Amarillo", "Azul", "Blanco", "Corinto", "Mostaza", "Naranja", "Negro", "Rojo", "Rosa", "Verde" }));

        estadoCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "En Venta", "En Reparación", "En Aduana", "En Tránsito" }));

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel8.setText("Formulario Consultar Automóvil");

        txtResultados.setEditable(false);
        txtResultados.setColumns(20);
        txtResultados.setRows(5);
        txtResultados.setText("Resultados:");
        jScrollPane1.setViewportView(txtResultados);

        chkBuscarMarca.setText("buscar");

        chkBuscarModelo.setText("buscar");

        chkBuscarLinea.setText("buscar");

        chkBuscarTipo.setText("buscar");

        chkBuscarColor.setText("buscar");

        chkBuscarEstado.setText("buscar");

        chkBuscarPlaca.setText("buscar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7))
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addComponent(btnConsultar)
                        .addGap(35, 430, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(estadoCB, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(chkBuscarEstado))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(placaTB)
                                    .addComponent(lineaTB, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(tipoCB, javax.swing.GroupLayout.Alignment.LEADING, 0, 95, Short.MAX_VALUE)
                                    .addComponent(marcaCB, javax.swing.GroupLayout.Alignment.LEADING, 0, 1, Short.MAX_VALUE)
                                    .addComponent(colorCB, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(modeloTF, javax.swing.GroupLayout.Alignment.LEADING))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(chkBuscarMarca)
                                    .addComponent(chkBuscarModelo)
                                    .addComponent(chkBuscarLinea)
                                    .addComponent(chkBuscarTipo)
                                    .addComponent(chkBuscarColor)
                                    .addComponent(chkBuscarPlaca))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 91, Short.MAX_VALUE)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(32, 32, 32))))
            .addGroup(layout.createSequentialGroup()
                .addGap(86, 86, 86)
                .addComponent(jLabel8)
                .addGap(30, 30, 30))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(marcaCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(chkBuscarMarca))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(modeloTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(chkBuscarModelo))
                        .addGap(4, 4, 4)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lineaTB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(chkBuscarLinea))
                        .addGap(8, 8, 8)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(tipoCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(chkBuscarTipo))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(colorCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(chkBuscarColor))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel6)
                                    .addComponent(estadoCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel7)
                                    .addComponent(placaTB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(chkBuscarPlaca)))
                            .addComponent(chkBuscarEstado))
                        .addGap(18, 18, 18))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(btnConsultar)
                .addGap(15, 15, 15))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultarActionPerformed
        buscar();
    }//GEN-LAST:event_btnConsultarActionPerformed

    private void marcaCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_marcaCBActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_marcaCBActionPerformed

    private void modeloTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modeloTFActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_modeloTFActionPerformed

    /**
     * @param args the command line arguments
     */
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConsultar;
    private javax.swing.JCheckBox chkBuscarColor;
    private javax.swing.JCheckBox chkBuscarEstado;
    private javax.swing.JCheckBox chkBuscarLinea;
    private javax.swing.JCheckBox chkBuscarMarca;
    private javax.swing.JCheckBox chkBuscarModelo;
    private javax.swing.JCheckBox chkBuscarPlaca;
    private javax.swing.JCheckBox chkBuscarTipo;
    private javax.swing.JComboBox colorCB;
    private javax.swing.JComboBox estadoCB;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField lineaTB;
    private javax.swing.JComboBox marcaCB;
    private javax.swing.JTextField modeloTF;
    private javax.swing.JTextField placaTB;
    private javax.swing.JComboBox tipoCB;
    private javax.swing.JTextArea txtResultados;
    // End of variables declaration//GEN-END:variables
}
